package com.active.test.spring;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @author lzy
 * @create 2019-11-26 下午5:01
 */
@Slf4j
@Component
public class MyMessageListener implements MessageListener {
    @Override
    public void onMessage(Message message) {
        if (message != null && message instanceof TextMessage) {
            TextMessage msg = (TextMessage) message;
            try {
                log.info("收到消息{}", msg.getText());
            } catch (JMSException e) {
                e.printStackTrace();
            }
        }
    }
}
